package com.sample.remote
{
	import com.sample.vo.UserVO;
	import com.trg.flex.remote.ROCall;
	import com.trg.flex.remote.RemoteCall;
	import com.trg.flex.remote.RemoteServiceLocator;
	import com.trg.flex.search.Search;
	
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.remoting.RemoteObject;

	
	public class UserServiceDelegate {
		
		private var remote : RemoteObject;

		
		public function UserServiceDelegate() {
			remote = RemoteServiceLocator.getInstance().getRemoteObject( 'userService' );
		}
		
		public function flush():RemoteCall {
			return new ROCall(remote, 'flush');
		}
		
		public function search(search:Object):RemoteCall {
			return new ROCall(remote, 'search', search);
		}
		
		public function create(user:UserVO):RemoteCall {
			return new ROCall(remote, 'create', user);
		}
		
		public function update(user:UserVO):RemoteCall {
			return new ROCall(remote, 'update', user);
		}
		
		public function fetchByLoginAndPassword(login:String, password:String):RemoteCall {
			return new ROCall(remote, 'fetchByLoginAndPassword', login, password);
		}
		
		public function fetchUserByLogin(login:String):RemoteCall {
			return new ROCall(remote, 'fetchUserByLogin', login);
		}
		
		public function addUser(user:UserVO, password:String):RemoteCall {
			return new ROCall(remote, 'addUser', user, password);
		}
		
		public function changePassword(userId:Number, newPassword:String):RemoteCall {
			return new ROCall(remote, 'changePassword', userId, newPassword);
		}
		
		public function deleteById(userId:Number):RemoteCall {
			return new ROCall(remote, 'deleteById', userId);
		}
		
		public function deleteEntity(user:UserVO):RemoteCall {
			return new ROCall(remote, 'deleteEntity', user);
		}
		
		public function fetch(userId:Number):RemoteCall {
			return new ROCall(remote, 'fetch', userId);
		}
		
		public function fetchAll():RemoteCall {
			return new ROCall(remote, 'fetchAll');
		}
		
		public function count(search:Search):RemoteCall {
			return new ROCall(remote, 'count', search);
		}
		
		public function searchAndCount(search:Search):RemoteCall {
			return new ROCall(remote, 'searchAndCount', search);
		}
		
		public function isConnected(object:Object):RemoteCall {
			return new ROCall(remote, 'isConnected', object);
		}
	}
}